from urllib.parse import urlparse,urlunparse
#拆分url
result=urlparse('https://search.jd.com/Searchprint;hello?keyword=python从菜鸟到高手&enc=utf-8#comment')
result1=urlparse('https://search.jd.com/Searchprint;hello?keyword=python从菜鸟到高手&enc=utf-8#comment',scheme='ftp',allow_fragments=False)

# print('scheme:',result.scheme)
# print('netloc:',result.netloc)
# print('path:',result.path)
# print('params:',result.query)
# print('query:',result.query)
# print('fragment:',result.fragment)
# print('-----------')

print('scheme:',result1.scheme)
print('fragment:',result1.fragment)
print('-------')

#合并不同部分，组成一个完整的url
data=['http','search.jd.com','Searchprint','world','keyword=python从菜鸟到高手&enc=utf-8','comment']

print(urlunparse(data))